package com.atchangsha.system.entity;

import com.atchangsha.system.vo.SalesBillVO;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 卓越班项目第二组
 * @date 2022-04-22 00:49:59
 */
@Data
@TableName("sales_bill")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SalesBillEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	@TableId(type = IdType.AUTO)
	private Long id;
	/**
	 * 订单编号
	 */
	private Long orderId;
	/**
	 * 消费金额
	 */
	private Float price;
	/**
	 * 折扣后金额
	 */
	private Float priceAfter;
	/**
	 * 账单时间
	 */
	@TableField(fill = FieldFill.INSERT)
	private Date time;
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	private Date createTime;
	/**
	 * 创建人
	 */
	private Long createBy;
	/**
	 * 逻辑删除标志：0：未删除，1：已删除
	 */
	@TableLogic
	private String removeFlag;

	/**
	 * 将entity对象转换成VO对象
	 *
	 * @return VO对象
	 */
	public SalesBillVO toEntity(){
		return SalesBillVO.builder()
				.id(id)
				.orderId(orderId)
				.price(price)
				.priceAfter(priceAfter)
				.time(time)
				.build();
	}

}
